package cn.glutnn.controller;


import cn.glutnn.entity.MembershipLevels;
import cn.glutnn.entity.Result;
import cn.glutnn.service.MembershipLevelsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.Serializable;
import java.util.List;

/**
 * (MembershipLevels)表控制层
 *
 * @author msh
 * @since 2024-12-14 17:06:20
 */
@RestController
@RequestMapping("/membershipLevels")
public class MembershipLevelsController {
    /**
     * 服务对象
     */
    @Autowired
    private MembershipLevelsService membershipLevelsService;


    @PostMapping
    public Result<String> save(@RequestBody MembershipLevels membershipLevels) {
        membershipLevelsService.save(membershipLevels);
        return Result.success("添加成功");
    }

    @DeleteMapping("/{id}")
    public Result<String> delete(@PathVariable("id") Integer id) {
        membershipLevelsService.removeById(id);
        return Result.success("删除成功");
    }

    @PutMapping
    public Result<String> update(@RequestBody MembershipLevels membershipLevels) {
        membershipLevelsService.updateById(membershipLevels);
        return Result.success("修改成功");
    }

    @GetMapping("/{id}")
    public Result<MembershipLevels> getById(@PathVariable("id") Integer id) {
        return Result.success(membershipLevelsService.getById(id));
    }

    @GetMapping("/list")
    public Result<List<MembershipLevels>> list() {
        return Result.success(membershipLevelsService.list());
    }
}

